package com.hargasembako.core.entity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.hargasembako.core.util.SearchJanitor;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ProductPrice {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
	private Long id;	
	@Persistent
	private Long productId;	
	@Persistent
	private String productName;	
	@Persistent
	private Long categoryId;
	@Persistent
	private String categoryName;
	@Persistent
	private Long brandId;
	@Persistent
	private String brandName;
	@Persistent
	private String thumbnail;
	@Persistent
	private Long storeId;
	@Persistent
	private String storeName;
	@Persistent
	private String cityName;	
	@Persistent
	private String stateName;	
	@Persistent
	private BigDecimal price;
	//tipe discount (0=% <-- isi field discountPersen, 1=Nominal <-- isi field discountAmount)
	@Persistent
	private Integer discountType;
	@Persistent
	private Float discountPersen;
	@Persistent
	private BigDecimal discountAmount;
	@Persistent
	private Date lastUpdate;
	@Persistent
	private Boolean active;
    @Persistent
    private Set<String> fts;
	
	public ProductPrice(Long productId, String productName, Long categoryId, String categoryName,
			Long brandId, String brandName, Long storeId, String storeName, String cityName, String stateName, BigDecimal price){
		
		this.productId = productId;
		this.productName = productName;
		this.categoryId = categoryId;
		this.categoryName = categoryName;
		this.brandId = brandId;
		this.brandName = brandName;
		this.storeId = storeId;
		this.storeName = storeName;
		this.cityName = cityName;
		this.stateName = stateName;
		this.price = price;
		
		this.fts = new HashSet<String>();
        
        SearchJanitor.updateFTSStuff(this.toString(), this.fts);		
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getProductId() {
		return productId;
	}
	public void setProductId(Long productId) {
		this.productId = productId;
	}
	
	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public Long getBrandId() {
		return brandId;
	}

	public void setBrandId(Long brandId) {
		this.brandId = brandId;
	}

	public String getBrandName() {
		return brandName;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public String getThumbnail() {
		return thumbnail;
	}

	public void setThumbnail(String thumbnail) {
		this.thumbnail = thumbnail;
	}

	public Long getStoreId() {
		return storeId;
	}

	public void setStoreId(Long storeId) {
		this.storeId = storeId;
	}

	public String getStoreName() {
		return storeName;
	}

	public void setStoreName(String storeName) {
		this.storeName = storeName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getStateName() {
		return stateName;
	}

	public void setStateName(String stateName) {
		this.stateName = stateName;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Integer getDiscountType() {
		return discountType;
	}

	public void setDiscountType(Integer discountType) {
		this.discountType = discountType;
	}

	public Float getDiscountPersen() {
		return discountPersen;
	}

	public void setDiscountPersen(Float discountPersen) {
		this.discountPersen = discountPersen;
	}

	public BigDecimal getDiscountAmount() {
		return discountAmount;
	}

	public void setDiscountAmount(BigDecimal discountAmount) {
		this.discountAmount = discountAmount;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}
	
	public Set<String> getFts() {
		return fts;
	}

	public void setFts(Set<String> fts) {
		this.fts = fts;
	}

	public String toString(){		
		return productName +" "+ categoryName +" "+ brandName +" "+ storeName +" "+ cityName +" "+ stateName; 
	}

}
